-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tab completion and syntax checking #261
Conversation
…e.rs into tab_complete
I think the bar idicates that the selection menu is active? The code should turn green when it has a number and at least two valid words in it. Yes "NO RECORDS FOUND" is not the ideal wording here. I have not looking into docs on how i can change this. I will see what we can do about it. |
src/core/wordlist.rs
Outdated
pub fn default_wordlist_flatned() -> Vec<String> { | ||
load_pgpwords() | ||
.iter() | ||
.flatten() | ||
.map(|s| s.clone()) | ||
.collect() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't think flattening is the right approach here. Which word is chosen depends on the current word index.
See https://github.com/magic-wormhole/magic-wormhole.rs/blob/main/src/core/wordlist.rs#L24 as for how it works. The list of possible words that is chosen depends on whether the word is at an even or odd position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah i see. That makes sense! Will look into this further...
I am currently thinking about how we can refactor the completion part into |
I find it rather unrealistic that one would need to do such a thing. However I don't really care much, you can add an optional pub fn get_completions(&self, prefix: &str, pos: Option<usize>) -> Vec<String>; where if pos is not set, it will use the prefix len? Alternatively you can just return no completions to reedline if pos != len - 1 and use the existing signature. If you add additional dependencies to the library crate for completions, please add them behind a feature flag (could call it completion) :) |
…e.rs into tab_complete
I've switched to And what am i missing with the |
@felinira When i run
Do we need to rethink how we use the default features in |
Yeah, that's on my list in my head for the next breaking change which would be 0.8. The entire crate needs a spring cleaning, which is easier once we have removed all deprecated items. I would however prefer to not do another breaking release for a little while longer, as it's always more work than anticipated. I don't have much time for it until EOY at least. The empty feature build should also be properly tested in CI. But as this also occurs in main I would consider it out of scope for this PR. But feel free to submit a PR, I suppose we need to branch 0.8 eventually. |
I will get #257 in first, because I would consider it a security fix, I hope it doesn't create too many conflicts. |
Thanks a lot, it works well for now, at least for me :) |
A really nice feature I would love is TAB completion for the wormhole codes. This is a fully functional and working prototype with the
reedline
crate, which provides most of the functionality already. I also decided to use fuzzy string searching using the Jaro-Winkler algorithm to autocomplete words containing spelling mistakes, especially for people with poor English language knowledge via verbal code propagation.TODO list:
core::wordlist
module public to access the wordlist in CLI. Some documentation is still missing there.Feedback would be appreciated. Let's make magick-wormhole.rs catch up with the og 😄
PS: i think this needs to be squashed, had some trouble merging with upstream after creating branch...